package com.da.finance;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.googlecode.cswish.annotation.cm;
import com.ra.landlord.LandlordOwner;
import com.ra.landlord.LandlordOwnerUser;
import com.ra.landlord.LandlordUser;

@Entity
@Table(name="da_dafinancecategory")
//财务类别
public class DaFinanceCategory implements LandlordOwner {
	
	public static final int FINANCE_CATEGORY_RENT = 1;			//租客房租
	public static final int FINANCE_CATEGORY_DEPOSIT = 2;		//租客押金
	public static final int FINANCE_CATEGORY_UNRENT = 3;		//租客退租
	public static final int FINANCE_CATEGORY_ACTIVITY = 9;      //活动
	

	public static final int FINANCE_CATEGORY_OWNER_RENT = 6;	    //业主房租
	public static final int FINANCE_CATEGORY_OWNER_DEPOSIT = 5;		//业主押金
	public static final int FINANCE_CATEGORY_OWNER_UNRENT = 8;		//业主退租
	
	public static final Integer PAYMENT_CATEGORY_INCOME = 1;	//收入
	public static final Integer PAYMENT_CATEGORY_EXPEND = 0;	//支出
	
	private Integer id;
	
	@cm("交易方")
	private String transaction;
	
	@cm("交易类型")
	private String tradeCategory;
	
	@cm("收支类型：0-支出，1-收入")
	private Integer paymentCategory;
	
	@cm("备注")
	private String remark;
	
	@cm("类别：0-用户添加的，1-系统添家的，不能修改")
	private Integer type;
	
	@cm("所属房东")
	private LandlordOwnerUser landlordUser;
	
	@cm("创建人")
	private LandlordUser createUser;
	
	@cm("创建日期")
	private Date createDate;

	@Id
	@GeneratedValue
	@OrderBy("id DESC")
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTransaction() {
		return transaction;
	}

	public void setTransaction(String transaction) {
		this.transaction = transaction;
	}

	public String getTradeCategory() {
		return tradeCategory;
	}

	public void setTradeCategory(String tradeCategory) {
		this.tradeCategory = tradeCategory;
	}

	public Integer getPaymentCategory() {
		return paymentCategory;
	}

	public void setPaymentCategory(Integer paymentCategory) {
		this.paymentCategory = paymentCategory;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@Override
	@ManyToOne(fetch=FetchType.LAZY)
	public LandlordOwnerUser getLandlordUser() {
		return landlordUser;
	}

	@Override
	public void setLandlordUser(LandlordOwnerUser landlordUser) {
		this.landlordUser=landlordUser;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, fetch=FetchType.LAZY)
	public LandlordUser getCreateUser() {
		return createUser;
	}

	public void setCreateUser(LandlordUser createUser) {
		this.createUser = createUser;
	}
	
	
}
